package com.mike.median.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class FileUtils {
    public static String readTxtFile(String fileName) throws IOException {
        StringBuilder result = new StringBuilder("");
        FileReader fileReader = null;
        BufferedReader bufferedReader = null;

        fileReader = new FileReader(new File(fileName));
        bufferedReader = new BufferedReader(fileReader);

        String read = null;
        while ((read = bufferedReader.readLine()) != null) {
            result.append(read);
        }

        if (bufferedReader != null) {
            bufferedReader.close();
        }

        if (fileReader != null) {
            fileReader.close();
        }

        return result.toString();
    }
}
